
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 01/03/2012 18:12:23
-- Generated from EDMX file: D:\TFS\Tizer\Tizer.Core\TizerDataBase.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [Tizer];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_CityAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Account] DROP CONSTRAINT [FK_CityAccount];
GO
IF OBJECT_ID(N'[dbo].[FK_AccountFolder]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Folder] DROP CONSTRAINT [FK_AccountFolder];
GO
IF OBJECT_ID(N'[dbo].[FK_AccountOrderSet]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OrderSet] DROP CONSTRAINT [FK_AccountOrderSet];
GO
IF OBJECT_ID(N'[dbo].[FK_AccountReview]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Review] DROP CONSTRAINT [FK_AccountReview];
GO
IF OBJECT_ID(N'[dbo].[FK_CountryAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Account] DROP CONSTRAINT [FK_CountryAccount];
GO
IF OBJECT_ID(N'[dbo].[FK_CityOutdoorSide]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OutdoorSide] DROP CONSTRAINT [FK_CityOutdoorSide];
GO
IF OBJECT_ID(N'[dbo].[FK_CountryCity]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[City] DROP CONSTRAINT [FK_CountryCity];
GO
IF OBJECT_ID(N'[dbo].[FK_CountryOutdoorSide]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OutdoorSide] DROP CONSTRAINT [FK_CountryOutdoorSide];
GO
IF OBJECT_ID(N'[dbo].[FK_FolderOutdoor]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Outdoor] DROP CONSTRAINT [FK_FolderOutdoor];
GO
IF OBJECT_ID(N'[dbo].[FK_OrderOutdoorSide]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OutdoorSide] DROP CONSTRAINT [FK_OrderOutdoorSide];
GO
IF OBJECT_ID(N'[dbo].[FK_OrderSetOrder]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Order] DROP CONSTRAINT [FK_OrderSetOrder];
GO
IF OBJECT_ID(N'[dbo].[FK_OutdoorSideOutdoor]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OutdoorSide] DROP CONSTRAINT [FK_OutdoorSideOutdoor];
GO
IF OBJECT_ID(N'[dbo].[FK_OutdoorSideSideDisabled]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[SideDisabled] DROP CONSTRAINT [FK_OutdoorSideSideDisabled];
GO
IF OBJECT_ID(N'[dbo].[FK_ReviewReview]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Review] DROP CONSTRAINT [FK_ReviewReview];
GO
IF OBJECT_ID(N'[dbo].[FK_ServiceService]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Service] DROP CONSTRAINT [FK_ServiceService];
GO
IF OBJECT_ID(N'[dbo].[FK_AccountService_Account]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[AccountService] DROP CONSTRAINT [FK_AccountService_Account];
GO
IF OBJECT_ID(N'[dbo].[FK_AccountService_Service]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[AccountService] DROP CONSTRAINT [FK_AccountService_Service];
GO
IF OBJECT_ID(N'[dbo].[FK_CurrencyOutdoorSide_Currency]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CurrencyOutdoorSide] DROP CONSTRAINT [FK_CurrencyOutdoorSide_Currency];
GO
IF OBJECT_ID(N'[dbo].[FK_CurrencyOutdoorSide_OutdoorSide]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CurrencyOutdoorSide] DROP CONSTRAINT [FK_CurrencyOutdoorSide_OutdoorSide];
GO
IF OBJECT_ID(N'[dbo].[FK_OutdoorFormat_Format]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OutdoorFormat] DROP CONSTRAINT [FK_OutdoorFormat_Format];
GO
IF OBJECT_ID(N'[dbo].[FK_OutdoorFormat_Outdoor]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OutdoorFormat] DROP CONSTRAINT [FK_OutdoorFormat_Outdoor];
GO
IF OBJECT_ID(N'[dbo].[FK_OutdoorSideSideType_OutdoorSide]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OutdoorSideSideType] DROP CONSTRAINT [FK_OutdoorSideSideType_OutdoorSide];
GO
IF OBJECT_ID(N'[dbo].[FK_OutdoorSideSideType_SideType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OutdoorSideSideType] DROP CONSTRAINT [FK_OutdoorSideSideType_SideType];
GO
IF OBJECT_ID(N'[dbo].[FK_ServiceServiceType_Service]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ServiceServiceType] DROP CONSTRAINT [FK_ServiceServiceType_Service];
GO
IF OBJECT_ID(N'[dbo].[FK_ServiceServiceType_ServiceType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ServiceServiceType] DROP CONSTRAINT [FK_ServiceServiceType_ServiceType];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Account]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Account];
GO
IF OBJECT_ID(N'[dbo].[City]', 'U') IS NOT NULL
    DROP TABLE [dbo].[City];
GO
IF OBJECT_ID(N'[dbo].[Country]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Country];
GO
IF OBJECT_ID(N'[dbo].[Currency]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Currency];
GO
IF OBJECT_ID(N'[dbo].[Folder]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Folder];
GO
IF OBJECT_ID(N'[dbo].[Format]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Format];
GO
IF OBJECT_ID(N'[dbo].[Order]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Order];
GO
IF OBJECT_ID(N'[dbo].[OrderSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[OrderSet];
GO
IF OBJECT_ID(N'[dbo].[Outdoor]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Outdoor];
GO
IF OBJECT_ID(N'[dbo].[OutdoorSide]', 'U') IS NOT NULL
    DROP TABLE [dbo].[OutdoorSide];
GO
IF OBJECT_ID(N'[dbo].[Review]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Review];
GO
IF OBJECT_ID(N'[dbo].[Service]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Service];
GO
IF OBJECT_ID(N'[dbo].[ServiceType]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ServiceType];
GO
IF OBJECT_ID(N'[dbo].[SideDisabled]', 'U') IS NOT NULL
    DROP TABLE [dbo].[SideDisabled];
GO
IF OBJECT_ID(N'[dbo].[SideType]', 'U') IS NOT NULL
    DROP TABLE [dbo].[SideType];
GO
IF OBJECT_ID(N'[dbo].[AccountService]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AccountService];
GO
IF OBJECT_ID(N'[dbo].[CurrencyOutdoorSide]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CurrencyOutdoorSide];
GO
IF OBJECT_ID(N'[dbo].[OutdoorFormat]', 'U') IS NOT NULL
    DROP TABLE [dbo].[OutdoorFormat];
GO
IF OBJECT_ID(N'[dbo].[OutdoorSideSideType]', 'U') IS NOT NULL
    DROP TABLE [dbo].[OutdoorSideSideType];
GO
IF OBJECT_ID(N'[dbo].[ServiceServiceType]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ServiceServiceType];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Account'
CREATE TABLE [dbo].[Account] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Login] nvarchar(max)  NOT NULL,
    [PasswordHash] nvarchar(max)  NOT NULL,
    [PasswordSalt] nvarchar(max)  NOT NULL,
    [IsApproved] bit  NOT NULL,
    [IsActive] bit  NOT NULL,
    [Email] nvarchar(max)  NULL,
    [CreatedDate] datetime  NOT NULL,
    [AccountTypeProperty] int  NOT NULL,
    [Company] nvarchar(max)  NULL,
    [Description] nvarchar(max)  NULL,
    [Logo] nvarchar(max)  NULL,
    [RatingVote] int  NOT NULL,
    [RatingScore] int  NOT NULL,
    [Map] nvarchar(max)  NULL,
    [Phone] int  NOT NULL,
    [Phone2] int  NOT NULL,
    [MobilePhone] int  NOT NULL,
    [Fax] int  NOT NULL,
    [ICQ] int  NOT NULL,
    [Website] nvarchar(max)  NULL,
    [GeoTarget] nvarchar(max)  NULL,
    [PublicEmail] nvarchar(max)  NULL,
    [PostalCode] int  NOT NULL,
    [Address] nvarchar(max)  NULL,
    [Address2] nvarchar(max)  NULL,
    [LastLoginDate] datetime  NOT NULL,
    [LastLockedOutDate] datetime  NOT NULL,
    [Country_ID] int  NULL,
    [City_ID] int  NULL
);
GO

-- Creating table 'City'
CREATE TABLE [dbo].[City] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Account_ID] int  NULL,
    [Country_ID] int  NULL
);
GO

-- Creating table 'Country'
CREATE TABLE [dbo].[Country] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NULL
);
GO

-- Creating table 'Currency'
CREATE TABLE [dbo].[Currency] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Code] nvarchar(max)  NULL,
    [Name] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Folder'
CREATE TABLE [dbo].[Folder] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NULL,
    [FolderTypeProperty] int  NOT NULL,
    [Account_ID] int  NULL
);
GO

-- Creating table 'Format'
CREATE TABLE [dbo].[Format] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NULL,
    [Description] nvarchar(max)  NULL,
    [IsPublished] bit  NOT NULL,
    [Icon] nvarchar(max)  NULL,
    [Width] int  NOT NULL,
    [Height] int  NOT NULL
);
GO

-- Creating table 'Order'
CREATE TABLE [dbo].[Order] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [StartDate] datetime  NOT NULL,
    [EndDate] datetime  NOT NULL,
    [Comment] nvarchar(max)  NULL,
    [OrderStatusProperty] int  NOT NULL,
    [OrderSet_ID] int  NULL
);
GO

-- Creating table 'OrderSet'
CREATE TABLE [dbo].[OrderSet] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [OrderDate] datetime  NOT NULL,
    [IsDeleted] bit  NOT NULL,
    [Account_ID] int  NULL
);
GO

-- Creating table 'Outdoor'
CREATE TABLE [dbo].[Outdoor] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [GeoTarget] nvarchar(max)  NULL,
    [Folder_ID] int  NULL
);
GO

-- Creating table 'OutdoorSide'
CREATE TABLE [dbo].[OutdoorSide] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Price] decimal(18,0)  NOT NULL,
    [Photo] nvarchar(max)  NULL,
    [Map] nvarchar(max)  NULL,
    [CreatedDate] datetime  NOT NULL,
    [ModifyDate] datetime  NOT NULL,
    [OfferTypeProperty] int  NOT NULL,
    [IsPubilshed] bit  NOT NULL,
    [Hits] int  NOT NULL,
    [HasBacklight] bit  NOT NULL,
    [Comment] nvarchar(max)  NULL,
    [OTS] decimal(18,0)  NOT NULL,
    [GRP] decimal(18,0)  NOT NULL,
    [GID] nvarchar(max)  NULL,
    [Address] nvarchar(max)  NULL,
    [IsDeleted] bit  NOT NULL,
    [Country_ID] int  NULL,
    [City_ID] int  NULL,
    [Outdoor_ID] int  NULL,
    [Order_ID] int  NULL
);
GO

-- Creating table 'Review'
CREATE TABLE [dbo].[Review] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Title] nvarchar(max)  NULL,
    [Positive] nvarchar(max)  NULL,
    [Negative] nvarchar(max)  NULL,
    [IsApproved] bit  NOT NULL,
    [CreateDate] datetime  NOT NULL,
    [ModifyDate] datetime  NOT NULL,
    [Author] nvarchar(max)  NULL,
    [AuthorEmail] nvarchar(max)  NULL,
    [Vote] int  NOT NULL,
    [IsPublished] bit  NOT NULL,
    [Parent_ID] int  NULL,
    [Account_ID] int  NULL
);
GO

-- Creating table 'Service'
CREATE TABLE [dbo].[Service] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NULL,
    [IsPublished] bit  NOT NULL,
    [Parent_ID] int  NULL
);
GO

-- Creating table 'ServiceType'
CREATE TABLE [dbo].[ServiceType] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NULL
);
GO

-- Creating table 'SideDisabled'
CREATE TABLE [dbo].[SideDisabled] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [StartDate] datetime  NOT NULL,
    [EndDate] datetime  NOT NULL,
    [OutdoorSide_ID] int  NULL
);
GO

-- Creating table 'SideType'
CREATE TABLE [dbo].[SideType] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NULL
);
GO

-- Creating table 'AccountService'
CREATE TABLE [dbo].[AccountService] (
    [Account_ID] int  NOT NULL,
    [Service_ID] int  NOT NULL
);
GO

-- Creating table 'CurrencyOutdoorSide'
CREATE TABLE [dbo].[CurrencyOutdoorSide] (
    [Currency_ID] int  NOT NULL,
    [OutdoorSide_ID] int  NOT NULL
);
GO

-- Creating table 'OutdoorFormat'
CREATE TABLE [dbo].[OutdoorFormat] (
    [Format_ID] int  NOT NULL,
    [Outdoor_ID] int  NOT NULL
);
GO

-- Creating table 'OutdoorSideSideType'
CREATE TABLE [dbo].[OutdoorSideSideType] (
    [OutdoorSide_ID] int  NOT NULL,
    [SideType_ID] int  NOT NULL
);
GO

-- Creating table 'ServiceServiceType'
CREATE TABLE [dbo].[ServiceServiceType] (
    [Service_ID] int  NOT NULL,
    [ServiceType_ID] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [ID] in table 'Account'
ALTER TABLE [dbo].[Account]
ADD CONSTRAINT [PK_Account]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'City'
ALTER TABLE [dbo].[City]
ADD CONSTRAINT [PK_City]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Country'
ALTER TABLE [dbo].[Country]
ADD CONSTRAINT [PK_Country]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Currency'
ALTER TABLE [dbo].[Currency]
ADD CONSTRAINT [PK_Currency]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Folder'
ALTER TABLE [dbo].[Folder]
ADD CONSTRAINT [PK_Folder]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Format'
ALTER TABLE [dbo].[Format]
ADD CONSTRAINT [PK_Format]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Order'
ALTER TABLE [dbo].[Order]
ADD CONSTRAINT [PK_Order]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'OrderSet'
ALTER TABLE [dbo].[OrderSet]
ADD CONSTRAINT [PK_OrderSet]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Outdoor'
ALTER TABLE [dbo].[Outdoor]
ADD CONSTRAINT [PK_Outdoor]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'OutdoorSide'
ALTER TABLE [dbo].[OutdoorSide]
ADD CONSTRAINT [PK_OutdoorSide]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Review'
ALTER TABLE [dbo].[Review]
ADD CONSTRAINT [PK_Review]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Service'
ALTER TABLE [dbo].[Service]
ADD CONSTRAINT [PK_Service]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'ServiceType'
ALTER TABLE [dbo].[ServiceType]
ADD CONSTRAINT [PK_ServiceType]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'SideDisabled'
ALTER TABLE [dbo].[SideDisabled]
ADD CONSTRAINT [PK_SideDisabled]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'SideType'
ALTER TABLE [dbo].[SideType]
ADD CONSTRAINT [PK_SideType]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [Account_ID], [Service_ID] in table 'AccountService'
ALTER TABLE [dbo].[AccountService]
ADD CONSTRAINT [PK_AccountService]
    PRIMARY KEY NONCLUSTERED ([Account_ID], [Service_ID] ASC);
GO

-- Creating primary key on [Currency_ID], [OutdoorSide_ID] in table 'CurrencyOutdoorSide'
ALTER TABLE [dbo].[CurrencyOutdoorSide]
ADD CONSTRAINT [PK_CurrencyOutdoorSide]
    PRIMARY KEY NONCLUSTERED ([Currency_ID], [OutdoorSide_ID] ASC);
GO

-- Creating primary key on [Format_ID], [Outdoor_ID] in table 'OutdoorFormat'
ALTER TABLE [dbo].[OutdoorFormat]
ADD CONSTRAINT [PK_OutdoorFormat]
    PRIMARY KEY NONCLUSTERED ([Format_ID], [Outdoor_ID] ASC);
GO

-- Creating primary key on [OutdoorSide_ID], [SideType_ID] in table 'OutdoorSideSideType'
ALTER TABLE [dbo].[OutdoorSideSideType]
ADD CONSTRAINT [PK_OutdoorSideSideType]
    PRIMARY KEY NONCLUSTERED ([OutdoorSide_ID], [SideType_ID] ASC);
GO

-- Creating primary key on [Service_ID], [ServiceType_ID] in table 'ServiceServiceType'
ALTER TABLE [dbo].[ServiceServiceType]
ADD CONSTRAINT [PK_ServiceServiceType]
    PRIMARY KEY NONCLUSTERED ([Service_ID], [ServiceType_ID] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [City_ID] in table 'Account'
ALTER TABLE [dbo].[Account]
ADD CONSTRAINT [FK_CityAccount]
    FOREIGN KEY ([City_ID])
    REFERENCES [dbo].[City]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CityAccount'
CREATE INDEX [IX_FK_CityAccount]
ON [dbo].[Account]
    ([City_ID]);
GO

-- Creating foreign key on [Account_ID] in table 'Folder'
ALTER TABLE [dbo].[Folder]
ADD CONSTRAINT [FK_AccountFolder]
    FOREIGN KEY ([Account_ID])
    REFERENCES [dbo].[Account]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AccountFolder'
CREATE INDEX [IX_FK_AccountFolder]
ON [dbo].[Folder]
    ([Account_ID]);
GO

-- Creating foreign key on [Account_ID] in table 'OrderSet'
ALTER TABLE [dbo].[OrderSet]
ADD CONSTRAINT [FK_AccountOrderSet]
    FOREIGN KEY ([Account_ID])
    REFERENCES [dbo].[Account]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AccountOrderSet'
CREATE INDEX [IX_FK_AccountOrderSet]
ON [dbo].[OrderSet]
    ([Account_ID]);
GO

-- Creating foreign key on [Account_ID] in table 'Review'
ALTER TABLE [dbo].[Review]
ADD CONSTRAINT [FK_AccountReview]
    FOREIGN KEY ([Account_ID])
    REFERENCES [dbo].[Account]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AccountReview'
CREATE INDEX [IX_FK_AccountReview]
ON [dbo].[Review]
    ([Account_ID]);
GO

-- Creating foreign key on [Country_ID] in table 'Account'
ALTER TABLE [dbo].[Account]
ADD CONSTRAINT [FK_CountryAccount]
    FOREIGN KEY ([Country_ID])
    REFERENCES [dbo].[Country]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CountryAccount'
CREATE INDEX [IX_FK_CountryAccount]
ON [dbo].[Account]
    ([Country_ID]);
GO

-- Creating foreign key on [City_ID] in table 'OutdoorSide'
ALTER TABLE [dbo].[OutdoorSide]
ADD CONSTRAINT [FK_CityOutdoorSide]
    FOREIGN KEY ([City_ID])
    REFERENCES [dbo].[City]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CityOutdoorSide'
CREATE INDEX [IX_FK_CityOutdoorSide]
ON [dbo].[OutdoorSide]
    ([City_ID]);
GO

-- Creating foreign key on [Country_ID] in table 'City'
ALTER TABLE [dbo].[City]
ADD CONSTRAINT [FK_CountryCity]
    FOREIGN KEY ([Country_ID])
    REFERENCES [dbo].[Country]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CountryCity'
CREATE INDEX [IX_FK_CountryCity]
ON [dbo].[City]
    ([Country_ID]);
GO

-- Creating foreign key on [Country_ID] in table 'OutdoorSide'
ALTER TABLE [dbo].[OutdoorSide]
ADD CONSTRAINT [FK_CountryOutdoorSide]
    FOREIGN KEY ([Country_ID])
    REFERENCES [dbo].[Country]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CountryOutdoorSide'
CREATE INDEX [IX_FK_CountryOutdoorSide]
ON [dbo].[OutdoorSide]
    ([Country_ID]);
GO

-- Creating foreign key on [Folder_ID] in table 'Outdoor'
ALTER TABLE [dbo].[Outdoor]
ADD CONSTRAINT [FK_FolderOutdoor]
    FOREIGN KEY ([Folder_ID])
    REFERENCES [dbo].[Folder]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FolderOutdoor'
CREATE INDEX [IX_FK_FolderOutdoor]
ON [dbo].[Outdoor]
    ([Folder_ID]);
GO

-- Creating foreign key on [Order_ID] in table 'OutdoorSide'
ALTER TABLE [dbo].[OutdoorSide]
ADD CONSTRAINT [FK_OrderOutdoorSide]
    FOREIGN KEY ([Order_ID])
    REFERENCES [dbo].[Order]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OrderOutdoorSide'
CREATE INDEX [IX_FK_OrderOutdoorSide]
ON [dbo].[OutdoorSide]
    ([Order_ID]);
GO

-- Creating foreign key on [OrderSet_ID] in table 'Order'
ALTER TABLE [dbo].[Order]
ADD CONSTRAINT [FK_OrderSetOrder]
    FOREIGN KEY ([OrderSet_ID])
    REFERENCES [dbo].[OrderSet]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OrderSetOrder'
CREATE INDEX [IX_FK_OrderSetOrder]
ON [dbo].[Order]
    ([OrderSet_ID]);
GO

-- Creating foreign key on [Outdoor_ID] in table 'OutdoorSide'
ALTER TABLE [dbo].[OutdoorSide]
ADD CONSTRAINT [FK_OutdoorSideOutdoor]
    FOREIGN KEY ([Outdoor_ID])
    REFERENCES [dbo].[Outdoor]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OutdoorSideOutdoor'
CREATE INDEX [IX_FK_OutdoorSideOutdoor]
ON [dbo].[OutdoorSide]
    ([Outdoor_ID]);
GO

-- Creating foreign key on [OutdoorSide_ID] in table 'SideDisabled'
ALTER TABLE [dbo].[SideDisabled]
ADD CONSTRAINT [FK_OutdoorSideSideDisabled]
    FOREIGN KEY ([OutdoorSide_ID])
    REFERENCES [dbo].[OutdoorSide]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OutdoorSideSideDisabled'
CREATE INDEX [IX_FK_OutdoorSideSideDisabled]
ON [dbo].[SideDisabled]
    ([OutdoorSide_ID]);
GO

-- Creating foreign key on [Parent_ID] in table 'Review'
ALTER TABLE [dbo].[Review]
ADD CONSTRAINT [FK_ReviewReview]
    FOREIGN KEY ([Parent_ID])
    REFERENCES [dbo].[Review]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ReviewReview'
CREATE INDEX [IX_FK_ReviewReview]
ON [dbo].[Review]
    ([Parent_ID]);
GO

-- Creating foreign key on [Parent_ID] in table 'Service'
ALTER TABLE [dbo].[Service]
ADD CONSTRAINT [FK_ServiceService]
    FOREIGN KEY ([Parent_ID])
    REFERENCES [dbo].[Service]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ServiceService'
CREATE INDEX [IX_FK_ServiceService]
ON [dbo].[Service]
    ([Parent_ID]);
GO

-- Creating foreign key on [Account_ID] in table 'AccountService'
ALTER TABLE [dbo].[AccountService]
ADD CONSTRAINT [FK_AccountService_Account]
    FOREIGN KEY ([Account_ID])
    REFERENCES [dbo].[Account]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Service_ID] in table 'AccountService'
ALTER TABLE [dbo].[AccountService]
ADD CONSTRAINT [FK_AccountService_Service]
    FOREIGN KEY ([Service_ID])
    REFERENCES [dbo].[Service]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AccountService_Service'
CREATE INDEX [IX_FK_AccountService_Service]
ON [dbo].[AccountService]
    ([Service_ID]);
GO

-- Creating foreign key on [Currency_ID] in table 'CurrencyOutdoorSide'
ALTER TABLE [dbo].[CurrencyOutdoorSide]
ADD CONSTRAINT [FK_CurrencyOutdoorSide_Currency]
    FOREIGN KEY ([Currency_ID])
    REFERENCES [dbo].[Currency]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [OutdoorSide_ID] in table 'CurrencyOutdoorSide'
ALTER TABLE [dbo].[CurrencyOutdoorSide]
ADD CONSTRAINT [FK_CurrencyOutdoorSide_OutdoorSide]
    FOREIGN KEY ([OutdoorSide_ID])
    REFERENCES [dbo].[OutdoorSide]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CurrencyOutdoorSide_OutdoorSide'
CREATE INDEX [IX_FK_CurrencyOutdoorSide_OutdoorSide]
ON [dbo].[CurrencyOutdoorSide]
    ([OutdoorSide_ID]);
GO

-- Creating foreign key on [Format_ID] in table 'OutdoorFormat'
ALTER TABLE [dbo].[OutdoorFormat]
ADD CONSTRAINT [FK_OutdoorFormat_Format]
    FOREIGN KEY ([Format_ID])
    REFERENCES [dbo].[Format]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Outdoor_ID] in table 'OutdoorFormat'
ALTER TABLE [dbo].[OutdoorFormat]
ADD CONSTRAINT [FK_OutdoorFormat_Outdoor]
    FOREIGN KEY ([Outdoor_ID])
    REFERENCES [dbo].[Outdoor]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OutdoorFormat_Outdoor'
CREATE INDEX [IX_FK_OutdoorFormat_Outdoor]
ON [dbo].[OutdoorFormat]
    ([Outdoor_ID]);
GO

-- Creating foreign key on [OutdoorSide_ID] in table 'OutdoorSideSideType'
ALTER TABLE [dbo].[OutdoorSideSideType]
ADD CONSTRAINT [FK_OutdoorSideSideType_OutdoorSide]
    FOREIGN KEY ([OutdoorSide_ID])
    REFERENCES [dbo].[OutdoorSide]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [SideType_ID] in table 'OutdoorSideSideType'
ALTER TABLE [dbo].[OutdoorSideSideType]
ADD CONSTRAINT [FK_OutdoorSideSideType_SideType]
    FOREIGN KEY ([SideType_ID])
    REFERENCES [dbo].[SideType]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OutdoorSideSideType_SideType'
CREATE INDEX [IX_FK_OutdoorSideSideType_SideType]
ON [dbo].[OutdoorSideSideType]
    ([SideType_ID]);
GO

-- Creating foreign key on [Service_ID] in table 'ServiceServiceType'
ALTER TABLE [dbo].[ServiceServiceType]
ADD CONSTRAINT [FK_ServiceServiceType_Service]
    FOREIGN KEY ([Service_ID])
    REFERENCES [dbo].[Service]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ServiceType_ID] in table 'ServiceServiceType'
ALTER TABLE [dbo].[ServiceServiceType]
ADD CONSTRAINT [FK_ServiceServiceType_ServiceType]
    FOREIGN KEY ([ServiceType_ID])
    REFERENCES [dbo].[ServiceType]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ServiceServiceType_ServiceType'
CREATE INDEX [IX_FK_ServiceServiceType_ServiceType]
ON [dbo].[ServiceServiceType]
    ([ServiceType_ID]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------